package formula.web;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;

import formula.business.model.Team;
import formula.business.repo.TeamRepository;

@SuppressWarnings("serial")
@ManagedBean
@SessionScoped
public class TeamsHome implements Serializable {

	public static final String EL_NAME = "#{teamsHome}";
	@ManagedProperty(value = TeamRepository.EL_NAME)
	private TeamRepository teamRepository;
	//
	private List<Team> teams;

	public void clear() {
		teams = null;
	}

	public void prepare() {
		teams = teamRepository.findAll();
	}

	public List<Team> getTeams() {
		if (teams == null)
			prepare();
		return teams;
	}

	public void setTeamRepository(TeamRepository _teamRepository) {
		teamRepository = _teamRepository;
	}
}
